home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 20
/
Cream of the Crop 20 (Terry Blount) (1996).iso
/
program
/
n_b_v203.zip
/
BIN$.DMO
< prev
next >
Wrap
Text File
|
1996-07-04
|
5KB
|
113 lines
$if 0
┌──────────────────────────╖ PowerBASIC v3.20
┌──┤ DASoft ╟──────────────────────┬──────────────────╖
│ ├──────────────────────────╢ Copyright 1995 │ DATE: 1995-10-01 ╟─╖
│ │ FILE NAME BIN$ .DMO ║ by ╘════════════════─ ║ ║
│ │ ║ Don Schullian, Jr. ║ ║
│ ╘══════════════════════════╝ ║ ║
│ A license is hereby granted to the holder to use this source code in ║ ║
│ any program, commercial or otherwise, without receiving the express ║ ║
│ permission of the copyright holder and without paying any royalties, ║ ║
│ as long as this code is not distributed in any compilable format. ║ ║
│ IE: source code files, PowerBASIC Unit files, and printed listings ║ ║
╘═╤═════════════════════════════════════════════════════════════════════╝ ║
│ .................................... ║
╘═══════════════════════════════════════════════════════════════════════╝
$endif
'.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°
' ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° °
$INCLUDE "DAS-NB01.INC"
SHARED sMask$ : sMask$ = "##,###,###,### or "
COLOR 7, 0
CLS
? "┌────────────────────────
? "│ fBIN$( Value&, Bytes? ) converts a decimal number into a binary
? "│ expression that has been padded and formatted
? "│ to the length you have requested.
? "│
? "│ fBINvalB?( B$ ) converts DASoft's binary strings or standard
? "│ binary strings back into decimal numbers.
? "├──────────────────────────────────────────────────────────────────────┘
? "│ fBIN$ creates binary strings that allow for easy viewing.
? "│ They can only be used, again, as numbers by fBINvalL&.
? "│ These routines were used to enhance the printing of binary
? "│ expressions while programming. It really started out as a little
? "│ programming tool but seems to have grown up!
? "└────────────────────────────────────────────────────────────────────────┘
LOCATE 15, 1 : PRINT "DASoft:"
LOCATE 16, 56 : PRINT "<HOME> & <END> +- 1"
LOCATE 17, 56 : PRINT "<UP> & <DOWN> +- 100"
LOCATE 18, 56 : PRINT "<PgUp> & <PgDn> +- 1000"
LOCATE 19, 1 : PRINT "PowerBASIC:"
LOCATE 25, 56 : PRINT "PRESS <ESC> TO END";
'┌──────────────────────
B? = 95 '│ assign some values
I% = 56 '│ to start with
L& = 65536 '│
DO '│
DisplayB B? '│ display the results
DisplayI I% '│
DisplayL L& '│
WHILE INSTAT : G$ = INKEY$ : WEND '│ clear the keyboard
WHILE NOT INSTAT : WEND '│ wait for a key press
SELECT CASE INKEY$ '│ evaluate the key press
CASE CHR$(27) : EXIT LOOP '│ <ESC> end program
CASE CHR$(000,071) : B? = MIN( 255, B? + 1) '│ <HOME> incr B?, 1
CASE CHR$(000,079) : B? = MAX( 0, B? - 1) '│ <END> decr B?, 1
CASE CHR$(000,072) : I% = MIN( 32767, I% + 100) '│ <UP> incr I%, 100
CASE CHR$(000,080) : I% = MAX(-32767, I% - 100) '│ <DOWN> decr I%, 100
CASE CHR$(000,073) : INCR L&, 1000 '│ <PgUp> incr L&, 1000
CASE CHR$(000,081) : DECR L&, 1000 '│ <PgDn> decr L&, 1000
END SELECT '│
LOOP '│
'────────────────────────────────────────────────────┼──────────────────────
CLS '│ end of program
END '│
'────────────────────────────────────────────────────┴──────────────────────
SUB DisplayB( BYVAL B? ) LOCAL PUBLIC
LOCAL B$
LOCATE 16, 1
B$ = fBIN$( B?, 1 )
B? = fBINvalB?( B$ )
PRINT USING sMask$; B?; : PRINT B$
LOCATE 20, 1
PRINT USING sMask$; B?;
PRINT LEFT$( BIN$( B? ) + SPACE$(32), 32 )
END SUB
SUB DisplayI( BYVAL I% ) LOCAL PUBLIC
LOCAL I$
LOCATE 17, 1
I$ = fBIN$( I%, 2 )
I% = fBINvalI%( I$ )
PRINT USING sMask$; I%; : PRINT I$
LOCATE 21, 1
PRINT USING sMask$; I%;
PRINT LEFT$( BIN$( I% ) + SPACE$(32), 32 )
END SUB
SUB DisplayL( BYVAL L& ) LOCAL PUBLIC
LOCAL L$
LOCATE 18, 1
L$ = fBIN$( L&, 4 )
L& = fBINvalL&( L$ )
PRINT USING sMask$; L&; : PRINT L$
LOCATE 22, 1
PRINT USING sMask$; L&;
PRINT LEFT$( BIN$( L& ) + SPACE$(32), 32 )
END SUB